package com.kyivmohyla.kma2.dao.mapper;

import com.kyivmohyla.kma2.model.Staff;
import org.springframework.jdbc.core.ResultSetExtractor;

import java.sql.ResultSet;
import java.sql.SQLException;

class StaffResultSetExtractor implements ResultSetExtractor<Staff> {

    @Override
    public Staff extractData(ResultSet resultSet) throws SQLException {
        Staff staff = new Staff();
        try {
            staff.setStaffId(resultSet.getInt("staff_id"));
            staff.setFirstName(resultSet.getString("first_name"));
            staff.setLastName(resultSet.getString("last_name"));
            staff.setEmail(resultSet.getString("email"));
            staff.setPassword(resultSet.getString("password"));
            staff.setPositionId(resultSet.getInt("position_id"));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return staff;
    }

}